#include "planning_process.hpp"
#include <memory>
#include <rclcpp/rclcpp.hpp>

int main(int argc, char* argv[])
{
    rclcpp::init(argc, argv);
    auto logger = rclcpp::get_logger("planning_process_node_cpp");

    try {
        auto node = std::make_shared<Planning::PlanningProcess>();
        RCLCPP_INFO(logger, "Startup complete");

        if (!node->process()) {
            RCLCPP_ERROR(logger, "Process failed, shutting down");
            rclcpp::shutdown(); // 先关闭上下文
            return 1; // 再优雅退出
        }

        rclcpp::spin(node); // 健康状态下才进入spin循环
        rclcpp::shutdown(); // 正常退出时关闭
    } catch (const std::exception& e) {
        RCLCPP_FATAL(logger, "Unhandled exception: %s", e.what());
    }
    return 0;
}
